var Qp_n = function (a) {
    this.m_colorarray = a;
    this.m_allitems = [];
    this.m_stepover = false;
    this.m_changeditems = [];
    this.m_fxarray = [];
};
Qp_n.prototype.randomMap = function () {
    for (var a = 0; a < qp_b; a++) {
        for (var b = 0; b < qp_a; b++) {
            var c = Math.floor(Math.random() * this.m_colorarray.length);
            this.m_allitems[a * qp_a + b] = new Qp_p(this.m_colorarray[c], a, b);
        }
    }
};
Qp_n.prototype.initfirstflood = function () {
    this.m_allitems[0].isflooded = true;
    this.m_changeditems.push(this.m_allitems[0]);
};
Qp_n.prototype.floodX = function (a, b) {
    for (var c = 0; c < qp_a; c++) {
        this.validij(c, b) && true == qp_k.m_allitems[b * qp_a + c].isflooded && b * qp_a + c < qp_a * qp_b - 1 && b * qp_a + c < (b + 1) * qp_a - 1 && false == qp_k.m_allitems[b * qp_a + c + 1].isflooded && qp_k.m_allitems[b * qp_a + c + 1].color == a && (this.m_stepover = false, qp_k.m_allitems[b * qp_a + c + 1].isflooded = true, this.m_fxarray.push(qp_k.m_allitems[b * qp_a + c + 1]));
    }
    for (c = qp_a - 1; 0 <= c; c--) {
        this.validij(c, b) && true == qp_k.m_allitems[b * qp_a + c].isflooded && 0 < b * qp_a + c && b * qp_a + c > b * qp_a && false == qp_k.m_allitems[b * qp_a + c - 1].isflooded && qp_k.m_allitems[b * qp_a + c - 1].color == a && (this.m_stepover = false, qp_k.m_allitems[b * qp_a + c - 1].isflooded = true, this.m_fxarray.push(qp_k.m_allitems[b * qp_a + c - 1]));
    }
};
Qp_n.prototype.floodY = function (a, b) {
    for (var c = 0; c < qp_b; c++) {
        this.validij(b, c) && true == qp_k.m_allitems[c * qp_a + b].isflooded && (c + 1) * qp_a + b < qp_a * qp_b && false == qp_k.m_allitems[(c + 1) * qp_a + b].isflooded && qp_k.m_allitems[(c + 1) * qp_a + b].color == a && (this.m_stepover = false, qp_k.m_allitems[(c + 1) * qp_a + b].isflooded = true, this.m_fxarray.push(qp_k.m_allitems[(c + 1) * qp_a + b]));
    }
    for (c = qp_b - 1; 0 <= c; c--) {
        this.validij(b, c) && true == qp_k.m_allitems[c * qp_a + b].isflooded && 0 < (c - 1) * qp_a + b && false == qp_k.m_allitems[(c - 1) * qp_a + b].isflooded && qp_k.m_allitems[(c - 1) * qp_a + b].color == a && (this.m_stepover = false, qp_k.m_allitems[(c - 1) * qp_a + b].isflooded = true, this.m_fxarray.push(qp_k.m_allitems[(c - 1) * qp_a + b]));
    }
};
Qp_n.prototype.flood = function (a, b) {
    for (this.m_fxarray = []; true != this.m_stepover;) {
        this.m_stepover = true;
        for (var c = 0; c < Math.max(qp_a, qp_b); c++) {
            this.floodY(a, c);
        }
        for (c = 0; c < Math.max(qp_a, qp_b); c++) {
            this.floodX(a, c);
        }
    }
    0 < this.m_fxarray.length && (qp_q(this.m_fxarray, a, b), qp_i.setStepNum_IncreaseOneStep());
    this.m_stepover = false;
};
Qp_n.prototype.validij = function (a, b) {
    return 0 > a || a >= qp_a || 0 > b || b >= qp_b ? false : true;
};
Qp_n.prototype.get1Dindex = function (a, b) {
    return this.validij(a, b) ? b * qp_a + a : -1;
};
Qp_n.prototype.isGameOver = function () {
    return qp_k.m_changeditems.length >= qp_a * qp_b ? true : false;
};